<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>系统登录</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <link rel="stylesheet" href="css/login.css">
    <style>
        /* 新增错误提示样式 */
        .error-alert {
            background-color: #f8d7da;
            color: #721c24;
            padding: 12px 20px;
            border-radius: 8px;

            margin-bottom: 20px;
            border: 1px solid #f5c6cb;
            display: flex;
            align-items: center;
            justify-content: space-between;
            animation: fadeIn 0.3s ease;
        }

        .error-alert .close-btn {
            background: none;
            border: none;
            color: #721c24;
            font-size: 18px;
            cursor: pointer;
            padding: 0;
            margin-left: 10px;
        }

        .error-alert .error-content {
            flex-grow: 1;
            display: flex;
            align-items: center;
        }

        .error-alert .error-icon {
            margin-right: 10px;
            font-size: 18px;
        }

        @keyframes fadeIn {
            from { opacity: 0; transform: translateY(-10px); }
            to { opacity: 1; transform: translateY(0); }
        }
    </style>
</head>
<body>
<div class="login-container">
    <div class="login-header">
        <i class="fas fa-user-shield"></i>
        <h1>欢迎登录</h1>
        <p>请输入您的账号和密码</p>
    </div>

    <!-- 错误提示区域 -->
    <c:if test="${not empty sessionScope.loginError}">
        <div class="error-alert">
            <div class="error-content">
                <i class="fas fa-exclamation-circle error-icon"></i>
                <span>${sessionScope.loginError}</span>
            </div>
            <button class="close-btn" onclick="this.parentElement.style.display='none'">
                <i class="fas fa-times"></i>
            </button>
        </div>
        <c:remove var="loginError" scope="session"/>
    </c:if>

    <form action="LoginServlet" method="post" class="login-form">
        <!-- 用户名输入框 -->
        <div class="form-group">
            <i class="fas fa-user icon"></i>
            <input type="text" name="username" placeholder="用户名" required value="${param.username}">
        </div>

        <!-- 密码输入框 -->
        <div class="form-group">
            <i class="fas fa-lock icon"></i>
            <input type="password" name="password" placeholder="密码" required>
        </div>

        <!-- 记住我和忘记密码 -->
        <div class="form-options">
            <label class="remember-me">
                <input type="checkbox" name="remember">
                <span>记住我</span>
            </label>
            <a href="#" class="forgot-password">忘记密码?</a>
        </div>

        <!-- 登录按钮 -->
        <button type="submit" class="login-button">
            <span>登 录</span>
            <i class="fas fa-arrow-right"></i>
        </button>
    </form>
</div>

<script>
    // 自动关闭错误提示
    document.addEventListener('DOMContentLoaded', function() {z
        const errorAlert = document.querySelector('.error-alert');
        if (errorAlert) {
            setTimeout(() => {
                errorAlert.style.opacity = '0';
                setTimeout(() => {
                    errorAlert.style.display = 'none';
                }, 300);
            }, 5000);
        }
    });
</script>
</body>
</html>